// $codepro.audit.disable packageJavadoc

package builder; 

import iface.Modificator;

import java.util.ArrayList;
import java.util.List;

import container.ProbabilityParameters;
import definition.Dice;

/**
 * Builder for a {@link ProbabilityParameters} Object.
 * 
 * @author Marcus Lindner
 * @author Joana Otetelisanu
 * 
 * @version $Revision$
 */
public class ProbabilityParameterBuilder {

    /**
     * Returns a new builder.
     * 
     * @return a new builder
     */
    public static ProbabilityParameterBuilder getBuilder() {
	final ProbabilityParameterBuilder builder = new ProbabilityParameterBuilder();
	builder.setAttackModifiers(new ArrayList<Modificator>());
	builder.setDefenseModifiers(new ArrayList<Modificator>());
	
	return builder;
    }
    
    private int attackModifier;
    private List<Modificator> attackModifiers;
    private int damageMultiplicator;
    private int defenseModifier;
    private List<Modificator> defenseModifiers;
    private Dice diceType;
    private boolean isAttackThreshold;
    private boolean isDefenseThreshold;
    private int numberOfAttackDices;
    private int numberOfDefenseDices;
    private int targetArmor;
    private boolean ap;
    private boolean weakFacing;

    /**
     * Applies the passed modificator as attack modificator;
     * 
     * @param modificator which is applied
     */
    public void applyAttackModificator(Modificator modificator) {
	this.attackModifier = this.attackModifier
		+ modificator.getModificator();
	this.attackModifiers.add(modificator);
    }

    /**
     * Applies the passed modificator as defense modificator;
     * 
     * @param modificator which is applied
     */
    public void applyDefenseModificator(Modificator modificator) {
	this.defenseModifier = this.defenseModifier
		+ modificator.getModificator();
	this.defenseModifiers.add(modificator);
    }

    /**
     * Builds a new {@link ProbabilityParameters} object on the basis of set
     * information.
     * 
     * @return parameter object
     */
    public ProbabilityParameters build() {
	final ProbabilityParameters parameters = new ProbabilityParameters();

	parameters.setAttackThreshold(this.isAttackThreshold);
	parameters.setDamageMultiplicator(this.damageMultiplicator);
	parameters.setDefenceThreshold(this.isDefenseThreshold);
	parameters.setTargetArmor(this.targetArmor);
	parameters.setAttackModifier(this.attackModifier);
	parameters.setAttackModifiers(this.attackModifiers);
	parameters.setDefenceModifiers(this.defenseModifiers);
	parameters.setDefenseModifier(this.defenseModifier);
	parameters.setDiceType(this.diceType);
	parameters.setNumberOfAttackDices(this.numberOfAttackDices);
	parameters.setNumberOfDefenseDices(this.numberOfDefenseDices);
	parameters.setAP(this.ap);
	parameters.setWeakFacing(this.weakFacing);
	
	return parameters;
    }


  

    /**
     * @param attModifier the attackModifier to set
     * @return the builder
     */
    public ProbabilityParameterBuilder setAttackModifier(int attModifier) {
	this.attackModifier = attModifier;
	return this;
    }

    /**
     * @param attModifiers the attackModifiers to set
     * @return the builder
     */
    public ProbabilityParameterBuilder setAttackModifiers(
	    List<Modificator> attModifiers) {
	this.attackModifiers = attModifiers;
	return this;
    }

    /**
     * @param isAttThreshold the isAttackThreshold to set
     * @return the builder
     */
    public ProbabilityParameterBuilder setAttackThreshold(boolean isAttThreshold) {
	this.isAttackThreshold = isAttThreshold;
	return this;
    }

    /**
     * @param dm the damageMultiplicator to set
     * @return the builder
     */
    public ProbabilityParameterBuilder setDamageMultiplicator(int dm) {
	this.damageMultiplicator = dm;
	return this;
    }

    /**
     * @param defModifier the defenseModifier to set
     * @return the builder
     */
    public ProbabilityParameterBuilder setDefenseModifier(int defModifier) {
	this.defenseModifier = defModifier;
	return this;
    }

    /**
     * @param defModifiers the defenceModifiers to set
     * @return the builder
     */
    public ProbabilityParameterBuilder setDefenseModifiers(
	    List<Modificator> defModifiers) {
	this.defenseModifiers = defModifiers;
	return this;
    }

    /**
     * @param isDefThreshold the isDefenceThreshold to set
     * @return the builder
     */
    public ProbabilityParameterBuilder setDefenseThreshold(
	    boolean isDefThreshold) {
	this.isDefenseThreshold = isDefThreshold;
	return this;
    }

    /**
     * @param type the diceType to set
     * @return the builder
     */
    public ProbabilityParameterBuilder setDiceType(Dice type) {
	this.diceType = type;
	return this;
    }

    /**
     * @param numberOfAttDices the numberOfAttackDices to set
     * @return the builder
     */
    public ProbabilityParameterBuilder setNumberOfAttackDices(
	    int numberOfAttDices) {
	this.numberOfAttackDices = numberOfAttDices;
	return this;
    }

    /**
     * @param numberOfDefDices the numberOfDefenseDices to set
     * @return the builder
     */
    public ProbabilityParameterBuilder setNumberOfDefenseDices(
	    int numberOfDefDices) {
	this.numberOfDefenseDices = numberOfDefDices;
	return this;
    }

    /**
     * @param armor the targetArmor to set
     * @return the builder
     */
    public ProbabilityParameterBuilder setTargetArmor(int armor) {
	this.targetArmor = armor;
	return this;
    }

    /**
     * @param pAp
     * @return this for chaining
     */
    public ProbabilityParameterBuilder setAP(boolean pAp) {
	this.ap = pAp;
	return this;
    }

    /**
     * @param pWeakFacing
     * @return this for chaining
     */
    public ProbabilityParameterBuilder setWeakFacing(boolean pWeakFacing) {
	this.weakFacing = pWeakFacing;
	return this;
    }
}
